#include "StdAfx.h"
#include "HBGKCapture.hxx"

#include "ChannelCapture.hxx"


HBGKCapture::HBGKCapture(void)
{
	_channels[ 0 ] = _channels[ 1 ] = _channels[ 2 ] = 0;
}


HBGKCapture::~HBGKCapture(void)
{
	for( int i = 0; i < CHANNEL_COUNT; i ++ )
	{
		if( _channels[ i ] )
		{
			delete _channels[ i ];
			_channels[ i ] = 0;
		}
	}
}

void HBGKCapture::initialize()
{
	for( int i = 0; i < CHANNEL_COUNT; i ++ )
	{
		_channels[ i ] = new ChannelCapture;

		_channels[ i ]->SetChannelId( i + 1 );
		_channels[ i ]->setDataCapture( this );
		_channels[ i ]->Login();
		
	}
}

void HBGKCapture::setChannelWnd( int channel, HWND wnd )
{
	if( _channels[ channel - 1 ] )
		_channels[ channel - 1 ]->SetDispWnd( wnd );
}

void HBGKCapture::start()
{
	DataCapture::start();
	
	char szCurrentDateTime[256];     
	SYSTEMTIME systm;     
	GetLocalTime(&systm);     
	sprintf( szCurrentDateTime, "%4d%.2d%.2d%.2d%.2d%.2d",     
		systm.wYear, systm.wMonth, systm.wDay,     
		systm.wHour, systm.wMinute, systm.wSecond ); 

	for( int i = 0; i < CHANNEL_COUNT; i ++ )
	{
		_channels[ i ]->InitializeFramePool();
		
		_channels[ i ]->CaptureRealData();
		_channels[ i ]->SetStartTime( szCurrentDateTime );
		_channels[ i ]->StartRecord();
	}
}

void HBGKCapture::stop()
{
}

void HBGKCapture::captureFrame()
{
}
